package com.tms.app.tms.ui.base.ui;

import android.support.v4.widget.SwipeRefreshLayout;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.tms.app.tms.R;
import com.tms.app.tms.bean.TestBean;
import com.tms.app.tms.ui.base.view.IListView;
import com.tms.app.tms.widget.CustomLoadMoreView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/10/28 0028.
 */

public abstract class BaseListActivity extends BaseActivity implements IListView {
    public List<TestBean> list=new ArrayList<>();
    protected BaseQuickAdapter adapter;
    protected CustomLoadMoreView customLoadMoreView;




    @Override
    protected void onStart() {
        super.onStart();
    }

    public void showNetError(){
        try {
            findViewById(R.id.net_errot_layout).setVisibility(View.VISIBLE);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void hideNerError(){
        try {
            findViewById(R.id.net_errot_layout).setVisibility(View.GONE);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }



    public BaseQuickAdapter getAdapter() {
        return adapter;
    }

    @Override
    public BaseQuickAdapter getAdapter(int type) {
        return adapter;
    }


    @Override
    public void pullMoreComlite(String... msg) {
        hideLoadingDialog();
        try {
            customLoadMoreView.setLoadMoreStatus(CustomLoadMoreView.STATUS_END);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }



    @Override
    public void pullMoreNoMore(String... msg) {
        hideLoadingDialog();
        try {
            customLoadMoreView.setLoadMoreStatus(CustomLoadMoreView.STATUS_END);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void refreshComplite(String... msg) {
        hideLoadingDialog();
        ((SwipeRefreshLayout) (findViewById(R.id.swipeLayout))).setRefreshing(false);
        hideNerError();
    }

    @Override
    public void refreshNoData(String... msg) {
        hideLoadingDialog();
        ((SwipeRefreshLayout) (findViewById(R.id.swipeLayout))).setRefreshing(false);
        showNetError();
    }
}
